<template>
	<view class="content poRel">
		<scroll-view style="height: 100vh;" scroll-y="true" class="scroll-Y" @scrolltolower="lower">
			<view v-if="list.length == 0" class="wid100 dis disAl disJuC" style="height: 80%;">
				<image src="../../static/incomeDetail/wushiju.png" style="width: 197rpx;height: 226rpx;"></image>
			</view>
			<view v-for="(item,index) in list" :key="index" @click="godetail(item.id)">
				<view class="wid90 mar mar-top30">
					<viwe class="dis ">
						<view class="textCen" style="width: 15%;">
							<image src="../../static/myGroup/tubiao.png" style="width: 46rpx;height: 60rpx;"></image>
						</view>
						<view style="width: 85%;">
							<view class="foSi40">{{item.name}}</view>
							<view class="foSi25 mar-top20 dis disAl" style="color: #AEACAC;">
								<image src="../../static/myGroup/weizhi.png" style="width: 24rpx;height: 32rpx;">
								</image>
								<view class="mar-left10">{{item.province_text}}-{{item.city_text}}-{{item.area_text}}
								</view>
							</view>
							<view class="foSi25 mar-top20" style="color: #AEACAC;">机构负责人：{{item.user}}</view>
							<view class="foSi25 mar-top20" style="color: #AEACAC;">负责人电话：{{item.user_phone}}</view>
							<view class="foSi25 mar-top20" style="color: #AEACAC;">所属业务员：{{item.uid_text}}</view>
							<view class="dis disAl foSi25 mar-top30">
								<view style="width: 33.33%;">
									<view>检查金额（元）</view>
									<view class="dis disAl mar-top20">
										<view class="mar-right20" style="font-weight: 600;">
											{{parseFloat(item.testing_amount).toFixed(2)}}</view>
										<view v-if="item.compare_testing_amount">
											<image v-if="item.compare_testing_amount>0"
												src="../../static/myGroup/shang.png"
												style="width: 30rpx;height: 25rpx;"></image>
											<image v-if="item.compare_testing_amount<0"
												src="../../static/myGroup/xia.png" style="width: 30rpx;height: 25rpx;">
											</image>
										</view>
									</view>
									<view v-if="!item.compare_testing_amount" class="mar-top20">-</view>
									<view v-if="item.compare_testing_amount" class="mar-top20"
										:style="item.compare_testing_amount>0?'color: #FF0000;':'color: #01ca96;'">较上周期
										{{item.compare_testing_amount}}</view>
								</view>
								<view style="width: 33.33%;">
									<view>检查项目</view>
									<view class="dis disAl mar-top20">
										<view class="mar-right20" style="font-weight: 600;">{{item.testing_num}}</view>
										<view v-if="item.compare_testing_num">
											<image v-if="item.compare_testing_num>0"
												src="../../static/myGroup/shang.png"
												style="width: 30rpx;height: 25rpx;"></image>
											<image v-if="item.compare_testing_num<0" src="../../static/myGroup/xia.png"
												style="width: 30rpx;height: 25rpx;"></image>
										</view>
									</view>
									<view v-if="!item.compare_testing_num" class="mar-top20">-</view>
									<view v-if="item.compare_testing_num" class="mar-top20"
										:style="item.compare_testing_num>0?'color: #FF0000;':'color: #01ca96;'">较上周期
										{{item.compare_testing_num}}</view>
								</view>
								<view style="width: 33.33%;">
									<view>检查订单</view>
									<view class="dis disAl mar-top20">
										<view class="mar-right20" style="font-weight: 600;">{{item.order_num}}</view>
										<view v-if="item.compare_order_num">
											<image v-if="item.compare_order_num>0" src="../../static/myGroup/shang.png"
												style="width: 30rpx;height: 25rpx;"></image>
											<image v-if="item.compare_order_num<0" src="../../static/myGroup/xia.png"
												style="width: 30rpx;height: 25rpx;"></image>
										</view>
									</view>
									<view v-if="!item.compare_order_num" class="mar-top20">-</view>
									<view v-if="item.compare_order_num" class="mar-top20"
										:style="item.compare_order_num>0?'color: #FF0000;':'color: #01ca96;'">较上周期
										{{item.compare_order_num}}</view>
								</view>
							</view>
						</view>
					</viwe>
				</view>
				<view style="height: 40rpx;"></view>
				<view v-if="(index+1)!=list.length" class="xhx"></view>
			</view>
			<view style="height: 100rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				xuanze: 1,
				inputValue: '',
				list: [],
				page: 0,
				datetimerange: [],
				last_page: 0,
				testing_amount: '',
				testing_num: '',
				team_num: '',
				clinic_num: '',
				// 判断是否还在继续输入
				timer: null,
				uid:''
			}
		},
		onLoad(option) {
			let that = this
			that.uid = option.uid
			
			this.dangqian()
		},
		methods: {
			godetail(id) {
				console.log(id)
				uni.navigateTo({
					url: '/pages/myGroup/instdetails?id=' + id
				})
			},
			dangqian() {
				this.zhanshi = 0
				var date = new Date()
				var year = date.getFullYear()
				var month = date.getMonth() + 1
				var day = date.getDate()
				this.datetimerange = [year + '-' + month + '-' + day, year + '-' + month + '-' + day]
				this.myteam()
			},
			chengType(index) {
				this.xuanze = index
				this.page = 0
				this.myteam()
			},
			changeTime(e) {
				this.datetimerange = e;
				if (e.length != 0) {
					this.page = 0
					this.myteam()
				}
			},
			myteam() {
				var that = this
				if (uni.getStorageSync('system_type') == 1) {
					var url = 'api/partner/myteam'

					if (this.xuanze != 0) {
						url = 'api/partner/cliniclist'
					}
				} else {
					var url = 'api/partner/myteam1'

					if (this.xuanze != 0) {
						url = 'api/partner/cliniclist1'
					}
				}
				url = 'api/partner/cliniclist2'
				uni.request({
					url: that.global.url + url,
					method: "POST",
					header: {
						'token': uni.getStorageSync('token')
					},
					data: {
						begintime: this.datetimerange[0],
						endtime: this.datetimerange[1],
						keywords: this.inputValue,
						uid:this.uid
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							if (that.xuanze != 0) {
								that.last_page = result.data.last_page
								if (that.page == 0) {
									that.list = result.data.data
								} else {
									that.list = that.list.concat(result.data.data)
								}
							} else {
								if (that.page == 0) {
									that.list = result.data.data.data
								} else {
									that.list = that.list.concat(result.data.data.data)
								}
								that.last_page = result.data.data.last_page
								that.testing_amount = result.data.testing_amount
								that.testing_num = result.data.testing_num
								that.team_num = result.data.team_num
								that.clinic_num = result.data.clinic_num
							}
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'error'
							})
						}

					}
				})
			},
			onKeyInput: function(event) {
				if (this.timer !== null) clearTimeout(this.timer)
				this.timer = setTimeout(() => {
					this.inputValue = event.target.value
					this.page = 0
					this.myteam()
				}, 1000)
			},
			lower: function(e) {
				if (this.last_page != this.page + 1) {
					this.page++
					this.myteam()
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				});
			},
		}
	}
</script>

<style>
	.content {}

	.uni-date-x--border {
		height: 90rpx;
	}
</style>